package com.pet.system.service.impl;

import com.pet.common.utils.DateUtils;
import com.pet.system.domain.PetCustomer;
import com.pet.system.mapper.PetCustomerMapper;
import com.pet.system.service.IPetCustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 客户Service业务层处理
 *
 * @author pet
 * @date 2022-10-09
 */
@Service
public class PetCustomerServiceImpl implements IPetCustomerService {
    @Autowired
    private PetCustomerMapper petCustomerMapper;

    /**
     * 查询客户
     *
     * @param id 客户主键
     * @return 客户
     */
    @Override
    public PetCustomer selectPetCustomerById(Long id) {
        return petCustomerMapper.selectPetCustomerById(id);
    }

    /**
     * 查询客户列表
     *
     * @param petCustomer 客户
     * @return 客户
     */
    @Override
    public List<PetCustomer> selectPetCustomerList(PetCustomer petCustomer) {
        return petCustomerMapper.selectPetCustomerList(petCustomer);
    }

    /**
     * 新增客户
     *
     * @param petCustomer 客户
     * @return 结果
     */
    @Override
    public int insertPetCustomer(PetCustomer petCustomer) {
        petCustomer.setCreateTime(DateUtils.getNowDate());
        return petCustomerMapper.insertPetCustomer(petCustomer);
    }

    /**
     * 修改客户
     *
     * @param petCustomer 客户
     * @return 结果
     */
    @Override
    public int updatePetCustomer(PetCustomer petCustomer) {
        petCustomer.setUpdateTime(DateUtils.getNowDate());
        return petCustomerMapper.updatePetCustomer(petCustomer);
    }

    /**
     * 批量删除客户
     *
     * @param ids 需要删除的客户主键
     * @return 结果
     */
    @Override
    public int deletePetCustomerByIds(Long[] ids) {
        return petCustomerMapper.deletePetCustomerByIds(ids);
    }

    /**
     * 删除客户信息
     *
     * @param id 客户主键
     * @return 结果
     */
    @Override
    public int deletePetCustomerById(Long id) {
        return petCustomerMapper.deletePetCustomerById(id);
    }
}
